<template>
	<view class="pagesBox">

		<img class="img" src="../../../static/img/mid.jpg" alt="">

		<view v-if="htmls" v-html="htmls">

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				htmls: null,
				mobile: '',
				parm: '',
				productId: ''
			}
		},
		onLoad(e) {
			this.parm = e.parm;
			this.productId = e.productId;
			this.mobile = e.mobile

			var userAgent = navigator.userAgent.toLowerCase();

			if (userAgent.indexOf('micromessenger') !== -1) {
				console.log('用户使用的是微信浏览器');
			} else {
				this.buyCard()
			}
		},
		methods: {
			buyCard() {


				uni.showLoading({
					title: "正在支付...",
					mask: true,
				});
				// var userAgent = navigator.userAgent.toLowerCase();
				let payChannle = 'ALIPAY'
				let payType = 'H5'
				this.$u.api.toPay({
						"parm": this.parm,
						"productId": this.productId,
						"mobile": this.mobile,
						payType,
						payChannle
					})
					.then(res => {
						this.htmls = res.data.alipayForm;
						this.$nextTick(() => {
							setTimeout(() => {
								window.document.forms[0].submit()
							}, 1000)
						})
					});

			},
		}
	}
</script>

<style scoped lang="scss">
	.img {
		width: 100%;
		display: block;
	}
</style>
